// login.js

// 创建 Vue 实例
new Vue({
    el: '#app',
    data: function() {
        return {
            username: '',
            password: ''
        };
    },
    methods: {
        login: async function() {
            try {
                const response = await axios.post('http://10.41.152.253:8000/login/', {
                    username: this.username,
                    password: this.password
                });
                const access = response.data.access;
                const refresh = response.data.refresh;
                localStorage.setItem('access_token', access);
                localStorage.setItem('refresh_token', refresh);
                // 跳转到指定页面
                window.location.href = './index.html';
            } catch (error) {
                console.error(error);
                alert('登录失败，请检查用户名和密码');
            }
        }
    }
});
